package com.member.web.controller.shop;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.member.common.annotation.Log;
import com.member.common.core.controller.BaseController;
import com.member.common.core.domain.AjaxResult;
import com.member.common.core.page.TableDataInfo;
import com.member.common.enums.BusinessType;
import com.member.common.utils.poi.ExcelUtil;
import com.member.shop.domain.SysBizWriteOff;
import com.member.shop.service.ISysBizWriteOffService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * 【核销】控制器
 *
 * @author lixinchen
 * @version 1.0
 * @date 2024-11-05
 **/
@RestController
@RequestMapping("/shop/writeOff")
public class SysBizWriteOffController extends BaseController {
    @Resource
    private ISysBizWriteOffService sysBizWriteOffService;

    /**
     * 查询核销列表
     */
    @PreAuthorize("@ss.hasPermi('shop:writeOff:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBizWriteOff sysBizWriteOff) {
        startPage();

        List<SysBizWriteOff> list = sysBizWriteOffService.selectSysBizWriteOffList(sysBizWriteOff);
        return getDataTable(list);
    }

    /**
     * 导出核销列表
     */
    @PreAuthorize("@ss.hasPermi('shop:writeOff:export')")
    @Log(title = "核销", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBizWriteOff sysBizWriteOff) {

        List<SysBizWriteOff> list = sysBizWriteOffService.selectSysBizWriteOffList(sysBizWriteOff);
        ExcelUtil<SysBizWriteOff> util = new ExcelUtil<SysBizWriteOff>(SysBizWriteOff. class);
        util.exportExcel(response, list, "核销数据");
    }

    /**
     * 获取核销详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:writeOff:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysBizWriteOffService.selectSysBizWriteOffById(id));
    }

    /**
     * 新增核销
     */
    @PreAuthorize("@ss.hasPermi('shop:writeOff:add')")
    @Log(title = "核销", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBizWriteOff sysBizWriteOff) {
        return toAjax(sysBizWriteOffService.insertSysBizWriteOff(sysBizWriteOff));
    }

    /**
     * 修改核销
     */
    @PreAuthorize("@ss.hasPermi('shop:writeOff:edit')")
    @Log(title = "核销", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBizWriteOff sysBizWriteOff) {
        return toAjax(sysBizWriteOffService.updateSysBizWriteOff(sysBizWriteOff));
    }

    /**
     * 删除核销
     */
    @PreAuthorize("@ss.hasPermi('shop:writeOff:remove')")
    @Log(title = "核销", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysBizWriteOffService.deleteSysBizWriteOffByIds(ids));
    }
}
